<template>
  <div>
    <h1 align="center">搜索书籍</h1>
    <el-card>
      <el-row :gutter="20">
        <el-col :span="15">
          <el-input placeholder="请输入搜索内容" v-model="querySearch.query">
            <el-button slot="append" icon="el-icon-search" @click="getSearchBook"></el-button>
          </el-input>
        </el-col>
      </el-row>
      <el-table :data="bookSearch" border stripe>
        <!--        索引列-->
        <el-table-column type="index"></el-table-column>
        <el-table-column label="图书名" prop="bookName"></el-table-column>
        <el-table-column label="价格" prop="price"></el-table-column>
        <el-table-column label="作者" prop="author"></el-table-column>
        <el-table-column label="图片">
          　　
          <template slot-scope="scope">
            <!--          显示图片-->
            　　　　<img :src="scope.row.picture" width="100" height="100"/>
          </template>

        </el-table-column>

        <el-table-column label="内容" prop="context"></el-table-column>
      </el-table>
    </el-card>

  </div>
</template>

<script>
export default {
  name: "Search",
  data() {
    return {
      bookSearch:[],
      querySearch:{
        query:""
      }
    }
  },
  methods:{
    getSearchBook(){
      axios.get(`/selectBook?bookName=${this.querySearch.query}`,this.bookSearch).then(res=>{
        console.log(res.data)
        this.bookSearch = res.data
      })
    },
  }
}
</script>

<style scoped>

</style>